<?php

namespace App\Jobs;

use App\Http\Services\ApiService;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class SendNoticeJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */

    private $schoolCode;
    private $params;

    public function __construct($schoolCode, $params)
    {
        $this->schoolCode = $schoolCode;
        $this->params = $params;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $schoolCode = $this->schoolCode;
        $params = $this->params;
        ApiService::sendNotice(
            $schoolCode,
            $params['card_number'],
            $params['title'],
            $params['content'],
            $params['sender'],
            $params['customs']
        );
    }
}
